<template>
  <div class="historical_det">
    <navigate>培训讲座详情</navigate>
    <div class="det_cont">
      <!-- tab切换 -->
      <div class="tab_list dis_flex white_box">
        <div class="item_tab" v-for="(item, index) in tabArr" :key="index" @click="chooseTab(index)"
          :class="currentTab == index ? 'active_tab' : ''">
          {{ item }}
        </div>
      </div>
      <basicInfo :info="taskInfo" v-if="currentTab == 0" />
      <historicalDetails v-if="currentTab == 1" :info="taskInfo.TaskInfo" />
      <insightsFeedback v-if="currentTab == 2" :info="taskInfo.info" @submitFeedback="submitFeedback" />
    </div>
  </div>
</template>


<script>
import historicalDetails from "./components/lectureDescription.vue";
import insightsFeedback from "./components/insightsFeedback.vue";
import basicInfo from "./components/basicInfo.vue";
import { formatDate } from '@/utils/time.js'
import { trainingLogInfo, feedbackInfo } from '@/api/funcation/training.js'

export default {
  data() {
    return {
      tabArr: ["讲座基本情况", "讲座事项说明", "填写心得反馈"],
      currentTab: 0,
      dataInfo: {},
      taskInfo: {},
      id: ''
    };
  },
  created() {
    this.id = this.$route.query.id
    this.getInfo()
  },
  components: { historicalDetails, insightsFeedback, basicInfo },
  methods: {
    formatDate,
    async getInfo() {
      let { data } = await trainingLogInfo({ id: this.id });
      this.taskInfo = data
    },
    //提交心得反馈
    async submitFeedback(val) {
      let par = {
        id: this.$route.query.id,
        is_know: val.is_know,
        learning: val.learning,
        content_level: val.content_level,
        lecturer_level: val.lecturer_level,
        suggestion: val.suggestion,
        lecturer_evaluate: val.lecturer_evaluate,
      }
      let res = await feedbackInfo(par)
      if (res.code == 200) {
        this.$toast.success('提交成功')
        this.getInfo()
      }
    },
    chooseTab(v) {
      this.currentTab = v;
    },
  },
};
</script>

<style lang="less" scoped>
.dis_flex {
  display: flex;
  align-items: center;
}

.just_center {
  justify-content: center;
}

.white_box {
  background: #ffffff;
  border-radius: 6.67px;
}

.historical_det {
  background-color: #f4f6fa;
  color: #333333;
  font-size: 14px;
}

.det_cont {
  padding: 10px;
}

//tab
.tab_list {
  height: 40px;
  line-height: 40px;
  margin-bottom: 10px;
}

.item_tab {
  flex: 1;
  height: 100%;
  text-align: center;
  font-weight: bold;
  font-size: 14.67px;
}

.active_tab {
  border-radius: 6.67px;
  color: #ffffff;
  background: linear-gradient(0deg, #ffffff -20%, rgba(255, 255, 255, 0) 20%),
    #00aeff;
}
</style>